Skip to content

feat: PLP and SRP page type support for handoff mode - #35

Merged
shilpi1998 merged 7 commits into
mainfrom
shilpi.mittal/plp-srp-handoff
Nov 17, 2026
Merged

shilpi1998 merged 7 commits into
mainfrom
shilpi.mittal/plp-srp-handoff

Conversation

@shilpi1998

@shilpi1998 shilpi1998 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Extend the shopper-agent handoff shim to support category pages (PLP) and search results pages (SRP) alongside the existing PDP flow
  • Add new custom element attributes: page-type, category-id, category-name, category-questions, search-query
  • Extend HandoffEventDetail with pageContextType and pageContextData so the host storefront can seed the main agent with the right page context on handoff
  • Dynamic pill sourcing per page type: pdpQuestions for PDP, categoryQuestions for PLP, none for SRP

New attributes

Attribute Type Description
page-type "pdp" | "plp" | "srp" Which storefront page the widget is on (default: "pdp")
category-id string Category ID for PLP pages (e.g. "mens-clothing-jackets")
category-name string Category display name for PLP pages (e.g. "Men's Jackets")
category-questions JSON string[] Pre-generated opener pills for PLP, analogous to pdp-questions
search-query string Search query for SRP pages

Handoff event changes

HandoffEventDetail now optionally includes:

pageContextType?: "pdp_inline" | "plp_inline" | "srp_inline";
pageContextData?: Record<string, unknown>;

The host storefront uses these to build the commerce_agent_context when opening the main Shopper Agent drawer.

Companion PR

  • Storefront: plugin_commerce_client PR #132 (passes PLP/SRP context to main agent via existing SRP flow — no BYON changes needed)

Test plan

  • All 267 unit tests pass
  • TypeScript compiles cleanly (pre-existing test type errors only)
  • Manual test: PDP handoff still works as before (regression)
  • Manual test: PLP handoff fires event with plp_inline context
  • Manual test: SRP handoff fires event with srp_inline context

Extend the shopper-agent handoff shim to support category (PLP) and
search results (SRP) pages alongside the existing PDP flow.

- Add page-type, category-id, category-questions, search-query attributes
- Extend HandoffEventDetail with pageContextType and pageContextData
- Dynamic pill sourcing: pdpQuestions for PDP, categoryQuestions for PLP
- Page-specific default placeholders
- Widen CommerceAgentContext.page_context_data to Record<string, unknown>
Add buildPlpInlineContext() and buildSrpInlineContext() to product-context.ts
so the widget sends the correct commerce_agent_context session variable on
every SCRT2 message regardless of page type.

Refactor the send path in WidgetProvider to use a unified resolveInlineContext()
that switches on config.pageType:
- pdp → buildPdpInlineContext (existing behavior)
- plp → buildPlpInlineContext with categoryId
- srp → buildSrpInlineContext with search query

Replace productContextRef with a broader pageContextRef that carries all
context-building fields to avoid stale closures in the sendMessage callback.
Pass categoryName (display name) in the handoff event so the
storefront can set SRP context with a meaningful query. Adds
category-name observed attribute and config field.
@shilpi1998
shilpi1998 marked this pull request as ready for review November 17, 2026 13:56
@shilpi1998
shilpi1998 changed the base branch from shilpi.mittal/hybrid-handoff-unify to main November 17, 2026 18:16
- Fix second version entry in package-lock.json to match 0.4.0
- Add tests for buildPlpInlineContext and buildSrpInlineContext
- Add ShopperAgentShim tests for PLP/SRP pills, placeholders, and
  handoff event context
@shilpi1998
shilpi1998 merged commit 5aae649 into main Nov 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant